package com.luyuan.crm.product.web.provider;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.SelectItem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.luyuan.crm.product.model.ProductType;
import com.luyuan.crm.product.service.ProductTypeService;
import com.ruijie.web.jsf.provider.AbstractSelectItemsProviderAdapter;

@Component("productTypeProvider")
public class ProductTypeProvider extends AbstractSelectItemsProviderAdapter implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Autowired
    private ProductTypeService productTypeService;

    public ProductTypeProvider() {
        super();
        setEnableEmpty(false);
    }

    @Override
    protected void populateSelectItems(List<SelectItem> list, Object... params) {
        List<ProductType> productTypes = productTypeService.getAll();
        for (ProductType model : productTypes) {
            SelectItem item = new SelectItem(model, model.getTypeName());
            list.add(item);
        }
    }

}
